<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
<html lang="zh-tw">
<head>
	<meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
 	<meta name="description" content="創業-支出結構-規畫你的創業第一年支出-創業e點通">  
	<title>收入結構-規畫你的創業第一年收入-創業e點通</title>

	<!-- reset.css -->
	<link rel="stylesheet" href="css/reset.css" media="screen">
	<!-- font-awesome.min.css -->
	<link rel="stylesheet" href="css/font-awesome.min.css" media="screen">
	<!-- grid1200 -->
	<link rel="stylesheet" href="css/skeleton.css">
	<!-- style -->
	<link rel="stylesheet" href="css/style.css">
	<!-- layout -->
	<link rel="stylesheet" href="css/layout.css">
	<!-- responsive-table -->
	<link rel="stylesheet" href="css/responsive-tables.css"  media="screen">
	<!-- alertify -->
	<link rel="stylesheet" href="css/alertify.css" />
	<link rel="stylesheet" href="css/alertify.default.css"/>	
	<!-- month picker -->
	<link rel="stylesheet" href="css/jquery-ui-1.9.2.custom.css">
	
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn’t work if you view the page via file:// -->
    
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>
<body>
	<header class="topheader clearfix">
		<div class="container">
			<div class="grid_12">
				<div class="logo">
					<a href="index"><img src="./images/egroup.png" alt="創業e點通品牌標誌"></a>
				</div><!-- logo -->
				<nav class="clearfix">
					<div class="top-nav">
						<div class="top-nav-right hideBlock">
							<c:choose>
								<c:when test="${loginMember!=null}">									
									<a id="loginButton"><span><i class="fa fa-user"></i> ${loginMember.name }，歡迎您登入</span></a>
									<ul class="loginDropdown hide">
										<li><a href="venturePlanMap">我的創業地圖</a></li>
										<li><a href="memberModi1">修改個人資料</a></li>	
										<li><a href="logout">登出</a></li>
									</ul>
								</c:when>
								<c:otherwise>
									<a href="memberLogin" id="loginButton"><span><i class="fa fa-user"></i>登入</span></a>
								</c:otherwise>
							</c:choose>
						</div>
					</div><!-- top-nav -->
				</nav>
			</div><!-- grid_12 -->
		</div><!-- container -->
	</header>
	<div class="wrapper">
		<div class="container">
			<div class="grid_12">
				<div class="banner">
					<div class="imgHolder"><img src="images/banner-office.jpg" alt="banner圖片-辦公室"></div>
				</div>
				<div class="breadcrumbs">
            		<p><a href="index">首頁</a> &gt; <a href="venturePlanMap">創業地圖</a> &gt; 
            		<a href="ventureCapitalPlanMap">創業第一年營運排程地圖</a> &gt; <span>收入結構</span></p>
	            </div>
			</div>

			<div class="grid_3">
				<aside>
					<ul class="sideNav hideBlock">
						<c:forEach var="i" begin="1" end="12"  step="1">		
							<li class="${selectedMonth==i?'current':''}">
							<a href="revenueStructure?m=${i}">${i}月 </a></li>						
						</c:forEach>							
					</ul>	
	                <div class="memberRwdnav clearfix">
	                    <nav class="primary">
	                        <ul class="rightnav">
	                        	<c:forEach var="i" begin="1" end="12"  step="1">		
									<li class="${selectedMonth==i?'current':''}">
									<a href="revenueStructure?m=${i}">${i}月 </a></li>						
								</c:forEach>	                                          
	                        </ul>
	                    </nav>
	                </div>          	
	            </aside>
	        </div>

	        <div class="grid_9">
				<section class="ventureTypesTitle hideBlock">
					<h2><i class="fa fa-money fa-color"></i>${selectedMonth}月收入結構</h2>
				</section>

				<form class="formset2">
				<p>收入結構 - 讓您清楚了解您的每月利潤及產品銷售數量，您可以點選編輯圖示，編輯您的產品資訊及銷售數量，藉此來調整您的收入結構</p>
				<br>
				<a class="addProduct" data-reveal-id ="addProduct"><i class="fa fa-plus"></i> 新增產品</a>
					<div class="ventureTypesInput clearfix">
						<ul>
							<li>
								<table class="productTable responsive">
									<thead>
										<tr>
											<th>產品名稱</th>
											<th>產品毛利</th>
											<th>月銷售數量</th>									
											<th>月利潤</th>
											<th>編輯</th>																						
											<th>刪除產品</th>
										</tr>
									</thead>
									<tbody>
									<c:forEach items="${getProductList1}" var="product" varStatus="i">		
										<tr>
											<td>${product.name }</td>
											<td>${product.profit }</td>
											<td>${product.sum }</td>											
											<td>${product.profit*product.sum}</td>
											<td>
												<a onclick="editProduct(${i.index});" 
												class="fa-color" data-reveal-id="editProduct" data-closeonbackgroundclick="false">
												<i class="fa fa-pencil-square-o fa-lg"></i></a>
											</td>
											<td>
												<a onclick="confirm(${i.index});" class="fa-color">		
												<i class="fa fa-times-circle fa-lg"></i></a>
											</td>
										</tr>						
									</c:forEach>									
								</tbody>
							</table>
							</li>
						</ul>
						<div class="text-center">
							<ul class="pagination">
								<c:forEach items="${page.pagerList}" var="pager">
									<li class="${pager.indexClass}"><a href="${pager.url}">${pager.index}</a></li>
								</c:forEach>			
				            </ul>
                        </div>
						<a href="ventureCapitalPlanMap" class="nextStepButton"><span class="next">回創業第一年營運排程地圖<i class="fa fa-arrow-right"></i></span></a>
					</div>
				</form>
			</div>
		</div>			
	</div>

	

	<!-- addProduct BEGIN MODAL WINDOWS -->
	<div id="addProduct" class="reveal-modal">
		<div class="cont clearfix">
			<form id="sendForm1" action="addProductRevenueStructure" method="post" class="formset clearfix">
			<input type="hidden" value="${param.m}" name="mon" id="mon1">	
				<fieldset class="fieldset2">
					<legend>1 產品名稱</legend>
					<div class="field">
						<label><span>產品名稱：</span> 
						<input type="text" class="form-control" name="name"> </label>
					</div>
				</fieldset>
				<fieldset class="fieldset2">
					<legend>2產品規格</legend>
					<textarea rows="8" name="specification"
						placeholder="產品內容物數量、產品長寬高、重量"></textarea>
				</fieldset>
				<fieldset class="fieldset2">
					<legend>3包裝說明</legend>
					<textarea rows="8" name="pack"
						placeholder="紙袋裝、紙盒裝、塑膠袋裝、真空包裝	"></textarea>
				</fieldset>
				<fieldset class="fieldset2">
					<legend>4終端消費者定價</legend>
					<div>
						<div class="field">
							<label>金額： <input type="text" name="endPrice" class="form-control">
							</label>
						</div>
					</div>
				</fieldset>
				<fieldset class="fieldset2">
					<legend>5實質銷售價格</legend>
					<div>
						<div class="field">
							<label>金額： <input type="text" name="salesPrice"	class="form-control">
							</label>
						</div>
					</div>
				</fieldset>
				<fieldset class="fieldset2">
					<legend>6直接成本</legend>
					<div>
						<div class="field">
							<label>金額： <input type="text" name="cost" class="form-control">
							</label>
						</div>
					</div>
				</fieldset>				
				<fieldset id="addSalesQuantityA" class="fieldset2">                               	
					<legend>7產品銷售數量 : </legend>								  			  	
					<button type="button" class="addbutton" onclick="addbuttonA();"><i class="fa fa-plus"></i> 新增數量</button>
					<div id="newMoneyA">
						
					</div>						  	
				</fieldset>
				<button type="submit" class="finishButton">
					<span class="next">新增產品</span>
				</button>
				<button type="button" class="cancelButton">
					<span class="next">取消</span>
				</button>
			</form>
		</div>
		<a class="close-reveal-modal">&#215;</a>
	</div>
	
	<!-- BEGIN MODAL WINDOWS -->
    <div id="editProduct" class="reveal-modal">
		<div class="cont clearfix">
			<form id="sendForm2" action="editProductRevenueStructure" method="post" class="formset clearfix">
			<input type="hidden" value="${param.m}" name="mon" id="mon2"> 
			<input type="hidden" value="${param.p}" name="page" id="page"> 		
			<input type="hidden" id="editProductID" name="id">
				<fieldset class="fieldset2">
					<legend>1 產品名稱</legend>
					<div class="field">
						<label><span>產品名稱：</span> 
						<input type="text" id= "editName" class="form-control" name="name"></label>
					</div>
				</fieldset>
				<fieldset class="fieldset2">
					<legend>2產品規格</legend>
					<textarea rows="8" id="editSpecification" name="specification"
						placeholder="產品內容物數量、產品長寬高、重量"></textarea>
				</fieldset>
				<fieldset class="fieldset2">
					<legend>3包裝說明</legend>
					<textarea rows="8" id="editPack" name="pack"
						placeholder="紙袋裝、紙盒裝、塑膠袋裝、真空包裝	"></textarea>
				</fieldset>
				<fieldset class="fieldset2">
					<legend>4終端消費者定價</legend>
					<div>
						<div class="field">
							<label>金額： <input type="text" id="endPrice" name="endPrice" class="form-control">
							</label>
						</div>
					</div>
				</fieldset>
				<fieldset class="fieldset2">
					<legend>5實質銷售價格</legend>
					<div>
						<div class="field">
							<label>金額： <input type="text" id="salesPrice" name="salesPrice"	class="form-control">
							</label>
						</div>
					</div>
				</fieldset>
				<fieldset class="fieldset2">
					<legend>6直接成本</legend>
					<div>
						<div class="field">
							<label>金額： <input type="text" id="editCost" name="cost" class="form-control">
							</label>
						</div>
					</div>
				</fieldset>
				<fieldset id="addSalesQuantityB" class="fieldset2">                               	
					<legend>7產品銷售數量 : </legend>								  			  	
					<button type="button" class="addbutton" onclick="addbuttonB();"><i class="fa fa-plus"></i> 新增數量</button>
					<div id="newMoneyB">
						
					</div>						  	
				</fieldset>
				<button type="submit" class="finishButton">
					<span class="next">修改產品</span>
				</button>
				<button type="button" class="cancelButton" >
					<span class="next">取消</span>
				</button>
			</form>
		</div>
		<a class="close-reveal-modal">&#215;</a>
	</div>
        
	<!-- import jquery -->	
	<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
	<!-- import nav slideToggle RWD js -->	
	<script src="js/nav.js"></script>
	<!-- Reveal Modal -->
	<script src="js/jquery.reveal.js"></script>
	<!-- jquery.mobilemenu.js -->
	<script src="js/jquery.validate.js"></script>
	<!-- month picker js -->
	<script src="js/jquery-ui-1.9.2.custom.js"></script>
	<!-- alertify js -->
	<script src="js/alertify.min.js"></script>
	<script src="js/messages_zh_TW.js"></script>
	<script src="js/additional-methods.js"></script>	
	<script type="text/javascript">
		//收入結構----------------------------------------------------------
		 $(function(){
	            $(".cancelButton").click(function(){
					$(".close-reveal-modal").trigger("click");
				});
	           
	            //sendForm1----------------------------------------------------------		           	 
	            $("#sendForm1").validate({
	            	//focus導致datepicker失效，暫時關閉
	            	focusInvalid:false,
	            	rules:{
	            		name:{
	            			required:true,
	            			maxlength:10
	            		},			
	            		specification:{
			    			required:true,
			    			maxlength:150
			    		},			
			    		pack:{
			    			required:true,
			    			maxlength:150
			    		},			
			    		endPrice:{
			    			required:true,
			    			number: true,
			    			maxlength:9,
			    			min:1,
			    			digits:true 
			    			
			    		},			
			    		salesPrice:{
			    			required:true,
			    			number: true,
			    			maxlength:9,
			    			min:1,
			    			digits:true 
			    		},			
			    		cost:{
			    			required:true,
			    			number: true,
			    			maxlength:9,
			    			min:1,
			    			digits:true 
			    			
			    		}
	            	},
	            	messages:{
	            		name:{
	            			required:"請輸入產品名稱",
	            			maxlength:"長度不能超過{0}"
	            		},
	            		specification:{
	            			required:"請輸入產品規格",
	            			maxlength:"長度不能超過{0}"
	            		},
	            		pack:{
	            			required:"請輸入包裝說明",
	            			maxlength:"長度不能超過{0}"
	            		},
	            		endPrice:{
	            			required:"請輸入終端消費者定價",
	            			number: "請輸入數字",
	            			maxlength:"請輸入小於10位數的金額",
	            			min:"請輸入大於0的金額",
	            			digits:"請輸入整數" 
	            		},
	            		salesPrice:{
	            			required:"請輸入實際銷售價格",
	            			number: "請輸入數字",
	            			maxlength:"請輸入小於10位數的金額",
	            			min:"請輸入大於0的金額",
	            			digits:"請輸入整數" 
	            		},
	            		cost:{
	            			required:"請輸入直接成本",
	            			number: "請輸入數字",
	            			maxlength:"請輸入小於10位數的金額",
	            			min:"請輸入大於0的金額",
	            			digits:"請輸入整數" 
	            		}
	            	},
    	        	submitHandler:function(form){
    					$(".salsDateA").attr("name","salsDate");
    					//form.submit();
    					$(".salsQuantityA").attr("name","salsQuantity");
    					form.submit();
    				}
	            });
	            
	         	//sendForm2----------------------------------------------------------
	            $("#sendForm2").validate({
	            	//focus導致datepicker失效，暫時關閉
	            	focusInvalid:false,
	            	rules:{
	            		name:{
	            			required:true,
	            			maxlength:10
	            		},			
	            		specification:{
			    			required:true,
			    			maxlength:150
			    		},			
			    		pack:{
			    			required:true,
			    			maxlength:150
			    		},			
			    		endPrice:{
			    			required:true,
			    			number: true,
			    			maxlength:9,
			    			min:1,
			    			digits:true 
			    			
			    		},			
			    		salesPrice:{
			    			required:true,
			    			number: true,
			    			maxlength:9,
			    			min:1,
			    			digits:true 
			    		},			
			    		cost:{
			    			required:true,
			    			number: true,
			    			maxlength:9,
			    			min:1,
			    			digits:true 
			    			
			    		}
	            	},
	            	messages:{
	            		name:{
	            			required:"請輸入產品名稱",
	            			maxlength:"長度不能超過{0}"
	            		},
	            		specification:{
	            			required:"請輸入產品規格",
	            			maxlength:"長度不能超過{0}"
	            		},
	            		pack:{
	            			required:"請輸入包裝說明",
	            			maxlength:"長度不能超過{0}"
	            		},
	            		endPrice:{
	            			required:"請輸入終端消費者定價",
	            			number: "請輸入數字",
	            			maxlength:"請輸入小於10位數的金額",
	            			min:"請輸入大於0的金額",
	            			digits:"請輸入整數" 
	            		},
	            		salesPrice:{
	            			required:"請輸入實際銷售價格",
	            			number: "請輸入數字",
	            			maxlength:"請輸入小於10位數的金額",
	            			min:"請輸入大於0的金額",
	            			digits:"請輸入整數" 
	            		},
	            		cost:{
	            			required:"請輸入直接成本",
	            			number: "請輸入數字",
	            			maxlength:"請輸入小於10位數的金額",
	            			min:"請輸入大於0的金額",
	            			digits:"請輸入整數" 
	            		}
	            	},
    	        	submitHandler:function(form){
    					$(".salsDateB").attr("name","salsDate");
    					form.submit();
    					$(".salsQuantityB").attr("name","salsQuantity");
    					form.submit();
    				}
	            });	 
	     	});	        	      	
	        
	      	
	      	var indexA = 0;
	        function addbuttonA(){
	        	var addnNewMoneyText =
				  	'<div class="deleteblock" id="newMoneyA'+indexA+'">'+
					'<div class="field">'+  	
					'<label>日期：'+		
					'<input class="form-control salsDateA monthYearPicker" id="salsDateA'+indexA+'" name="salsDateA'+indexA+'" readonly>'+  			
					'</label>'+  		
					'</div>'+  	
					'<div class="field">'+  	
					'<label>數量：'+ 		
					'<input type="text" class="form-control salsQuantityA"  id="salsQuantityA'+indexA+'" name="salsQuantityA'+indexA+'">'+ 			
					'</label>'+  		
					'</div>'+  	
					'<div class="field">'+  	
					'<button type="button" class="deletebutton" onclick="deletebuttonA('+indexA+');"><i class="fa fa-times"></i> 刪除</button>'+  		
					'</div>'+  				  		
				  	'</div>';	            		
	            	$('#addSalesQuantityA').append(addnNewMoneyText);
	            	addValidateA(indexA);
	            	indexA++;
	        }
	      	
	        function addValidateA(getIndex){
	        	$("#salsDateA"+getIndex).rules("add",{
	        		required:true,
	            	messages:{
	            		required:"請輸入日期",	            		
	            	}
	        	});	        	

	        	$("#salsQuantityA"+getIndex).rules("add",{
	        		required:true,
	            	number: true,
	            	min:1,
	            	maxlength:9,
        			digits: true,
	            	messages:{
	            		required:"請輸入數量",
	            		num:"請輸入數字",
	            		min:"請輸入大於0的數量",
	            		maxlength:"請輸入小於10位數的數量",
            			digits:"請輸入整數" 
	            	}
	        	});
	        }	
	        
	        function deletebuttonA(indexA){
            	$("#newMoneyA"+indexA).remove(); 
            	index--;
           	}
	        
	      	//收入sendForm2 function----------------------------------------------------------
	      	var indexB = 0;
	        function addValidateB(getIndex){
	        	$("#salsDateB"+getIndex).rules("add",{
	        		required:true,
	            	messages:{
	            		required:"請輸入日期",	            		
	            	}
	        	});	        	

	        	$("#salsQuantityB"+getIndex).rules("add",{
	        		required:true,
	            	number: true,
	            	min:1,
	            	maxlength:9,
        			digits: true,
	            	messages:{
	            		required:"請輸入數量",
	            		num:"請輸入數字",
	            		min:"請輸入大於0的數量",
	            		maxlength:"請輸入小於10位數的數量",
            			digits:"請輸入整數" 
	            	}
	        	});
	        }		
	        
	        function addbuttonB(){
	        	var addnNewMoneyText =
				  	'<div class="deleteblock" id="newMoneyB'+indexB+'">'+
					'<div class="field">'+  	
					'<label>日期：'+		
					'<input class="form-control salsDateB monthYearPicker" id="salsDateB'+indexB+'" name="salsDateB'+indexB+'" readonly>'+  			
					'</label>'+  		
					'</div>'+  	
					'<div class="field">'+  	
					'<label>數量：'+ 		
					'<input type="text" class="form-control salsQuantityB"  id="salsQuantityB'+indexB+'" name="salsQuantityB'+indexB+'">'+ 			
					'</label>'+  		
					'</div>'+  	
					'<div class="field">'+  	
					'<button type="button" class="deletebutton" onclick="deletebuttonB('+indexB+');"><i class="fa fa-times"></i> 刪除</button>'+  		
					'</div>'+  				  		
				  	'</div>';	            		
	            	$('#newMoneyB').append(addnNewMoneyText);
	            	addValidateB(indexB);
	            	indexB++;
	        }
	        
	        function deletebuttonB(indexB){
            	$("#newMoneyB"+indexB).remove(); 
            	indexB--;
           	}
	        
	    	function editProduct(i){
	       		var list = $.parseJSON('${getProductList2}');
				$('#editProductID').val(list[i].id);
				$("#editName").val(list[i].name);
				$("#editSpecification").val(list[i].specification);
				$("#editPack").val(list[i].pack);
				$("#endPrice").val(list[i].endPrice);
				$("#salesPrice").val(list[i].salesPrice);
				$("#editCost").val(list[i].cost);
				$.ajax({
					url:"getProductAndSalesListByMemberID",
					data:{
						productID : list[i].id
					},
					dataType:"json",
					success:function(result){
						$('#newMoneyB').html('');
						if(result.length>0){		
							for(var j=0; j<result.length; j++){
        	
								addnNewMoneyText = 
								  	'<div class="deleteblock" id="newMoneyB'+j+'">'+
									'<div class="field">'+  	
									'<label>日期：'+		
									'<input class="form-control salsDateB monthYearPicker" id="salsDateB'+j+'" name="salsDateB'+j+'" value="'+result[j].date_string+'" readonly>'+  			
									'</label>'+  		
									'</div>'+  	
									'<div class="field">'+  	
									'<label>數量：'+ 		
									'<input type="text" class="form-control salsQuantityB" id="salsQuantityB'+j+'" name="salsQuantityB'+j+'" value="'+result[j].quantity+'">'+ 			
									'</label>'+  		
									'</div>'+  	
									'<div class="field">'+  	
									'<button type="button" class="deletebutton" onclick="deletebuttonB('+j+');"><i class="fa fa-times"></i> 刪除</button>'+  		
									'</div>'+  				  		
								  	'</div>';	
				            	$('#newMoneyB').append(addnNewMoneyText);
				            	addValidateB(j);
				            	indexB++;
							}							
						}
					}
				});
	       	};
	        
	      	//------------------------------------------------------------------------------
	      	//彈出刪除視窗選擇
	      	 function reset() {
				$("#toggleCSS").attr("href", "css/alertify.default.css");
				alertify.set({
					labels : {
						ok     : "確認刪除",
						cancel : "取消"
					},
					delay : 5000,
					buttonReverse : false,
					buttonFocus   : "ok"
				});
			}
	        
	        function confirm(i){
	        	var list = $.parseJSON('${getProductList2}');
				var productName =list[i].name;
	        	reset();
	   			alertify.confirm("請問您確定要刪除"+productName+"?", function (e) {
	   				if (e) {
	   					$.ajax({
	   						url:"delProductRevenueStructure",
	   						data:{
	   							productID : list[i].id,
	   							getPage : $("#page").val()!==''?$("#page").val():'0'
	   						},
	   						dataType:"json",
	   						success:function(result){
	   							location.reload();	 
	   							alertify.success("刪除成功!");	
	   		   					window.open('revenueStructure?p='+result+"&m="+$("#mon1").val(), '_self');
	   						}
	   					});	   					
	   					
	   					
	   				} else {
	   					alertify.error("取消刪除!");
	   				}
   				});
   				return false;
	        }
					
			function calculateEndDate(startDate){
				var endDate;
				var endYear = parseInt(startDate.substring(0,4));
				var endMon = parseInt(startDate.substring(5,7))-1;
				if(endMon == 0){
					endDate = endYear+'-12';
				}else{
					endYear++;
					endMon = '0'+endMon;
					endDate = endYear+'-'+endMon.substring(endMon.length-2,endMon.length);
				}
				return endDate;
			}
			
			//------------------------------------------------------------------------------
			// month picker
			//設定日期限制的年月
			var yearMin = '${fn:substring(getMember.capitalDate,0,4)}';
			var monthMin = '${fn:substring(getMember.capitalDate,5,7)}';
			var yearMax = (calculateEndDate('${fn:substring(getMember.capitalDate,0,7)}')).substring(0,4);
			var monthMax = (calculateEndDate('${fn:substring(getMember.capitalDate,0,7)}')).substring(5,7);
			
			$('form').on('focus',".monthYearPicker", function(){
    			$(this).datepicker({    				
					changeMonth: true,
					changeYear: true,
					showButtonPanel: true,
					dateFormat: 'yy-MM',
					showMonthAfterYear: true,
					
					//日期限制
					minDate: new Date(yearMin, monthMin-1, 1),
					maxDate: new Date(yearMax, monthMax-1, 1)
				}).focus(function() {					
					var thisCalendar = $(this);
					$('.ui-datepicker-calendar').detach();
					$('.ui-datepicker-close').click(function() {						
						//$(this).find("input").removeClass("hasDatepicker").removeAttr("id");	
						var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
						var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
						thisCalendar.datepicker('setDate', new Date(year, month, 1));
						$('#sendForm1').valid();
						$('#sendForm2').valid();
						//alert('');						
					});
				});
			});	
	    </script>
</body>
</html>